package com.shkco.basic.config;

import com.shkco.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有请求
        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
                // 放行登录有关的请求
                .excludePathPatterns("/login/**")
                // 放行注册有关的请求
                .excludePathPatterns("/user/register/**","/shop/settlement","/verifyCode/**","/fastDfs/**")
                // 放行swagger
                .excludePathPatterns("/swagger-resources/**", "/webjars/**","/v2/**", "/swagger-ui.html/**");
    }
}
